import http from './http'
// 封装注册接口  http://localhost:12345/api/user/register
export const registerApi = (username,password)=>{
    return http({
        url:'http://localhost:12345/api/user/register',
        method:'POST',
        data:{
            username,password
        }
    })
}
// 封装登录接口  http://localhost:12345/api/user/login
export const loginApi = (username,password)=>{
    return http({
        url:'http://localhost:12345/api/user/login',
        method:'POST',
        data:{
            username,password
        }
    })
}
// 搜索接口 https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch
export const searchApi = (query)=>{
    return http({
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch',
        method:'GET',
        params:{
            query
        }
    })
}
// 封装分类接口 https://api-hmugo-web.itheima.net/api/public/v1/categories
export const claApi = ()=>{
    return http({
        url:'https://api-hmugo-web.itheima.net/api/public/v1/categories',
        method:'GET'
    })
}
// 封装详情接口 https://api-hmugo-web.itheima.net/api/public/v1/goods/detail
export const detailApi = (goods_id)=>{
    return http({
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/detail',
        method:'GET',
        params:{
            goods_id
        }
    })
}
//封装商品列表 https://api-hmugo-web.itheima.net/api/public/v1/goods/search
export const goodsApi = (query)=>{
    return http({
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/search',
        method:'GET',
        params:{
            query
        }
    })
}
// 封装生成订单 http://localhost:12345/api/order/create 五个参数
export const orderApi = (data)=>{
    return http({
        url:'http://localhost:12345/api/order/create',
        method:'POST',
        data:{
            ...data
        }
    })
}
// 订单详情 http://localhost:12345/api/order/getOrder/
export const orderdetailApi = (orderId)=>{
    return http({
        url:'http://localhost:12345/api/order/getOrder/'+orderId,
        method:'GET',
    })
}
// 订单支付 http://localhost:12345/api/order/pay
export const paylApi = (data)=>{
    return http({
        url:'http://localhost:12345/api/order/pay',
        method:'POST',
        data:{
            ...data
        }
    })
}
// 获取订单列表  http://localhost:12345/api/order/getOrderList/zhangsan
export const myorderlApi = (username)=>{
    return http({
        url:' http://localhost:12345/api/order/getOrderList/'+username,
        method:'GET',
    })
}